import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

/**
 * 引入axios，并将axios注入到vue
 */
import '@/service'

Vue.use(ElementUI);
Vue.config.productionTip = false;

//路由验证登录
router.beforeEach(function (to, from, next) {

  var user = localStorage.getItem("token");

  if (to.path == '/regView') {
    next()
    return
  }

  if (user != null || to.path === '/login') {
    next();
  } else {
    if (user === null || user === '') {
      next('/login');
    }
  }
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')